import django_filters
from .models import *


class UsersFilter(django_filters.FilterSet):
    username = django_filters.CharFilter(lookup_expr='icontains')
    institution = django_filters.CharFilter(lookup_expr='exact')

    class Meta:
        model = User
        fields = ['username', 'institution']  # 其他可过滤字段


class MenusFilter(django_filters.FilterSet):
    module = django_filters.CharFilter(lookup_expr='exact')
    name = django_filters.CharFilter(lookup_expr='icontains')

    class Meta:
        model = MenusModel
        fields = ['module', 'name']  # 其他可过滤字段


class AdmDivCodeFilter(django_filters.FilterSet):
    name = django_filters.CharFilter(lookup_expr='icontains')

    class Meta:
        model = AdmDivCodeModel
        fields = ['name']  # 其他可过滤字段


class FlowFilter(django_filters.FilterSet):
    name = django_filters.CharFilter(lookup_expr='icontains')

    class Meta:
        model = FlowModel
        fields = ['name']  # 其他可过滤字段


class ModulesFilter(django_filters.FilterSet):
    name = django_filters.CharFilter(lookup_expr='icontains')
    code = django_filters.CharFilter(lookup_expr='exact')

    class Meta:
        model = ModulesModel
        fields = ['name', 'code']  # 其他可过滤字段


class InstitutionsFilter(django_filters.FilterSet):
    name = django_filters.CharFilter(lookup_expr='icontains')
    admdivcode = django_filters.CharFilter(lookup_expr='exact')
    code = django_filters.CharFilter(lookup_expr='exact')

    class Meta:
        model = InstitutionsModel
        fields = ['admdivcode', 'name', 'code']  # 其他可过滤字段


class DataBaseFilter(django_filters.FilterSet):
    name = django_filters.CharFilter(lookup_expr='icontains')

    class Meta:
        model = DataBaseModel
        fields = ['name']  # 其他可过滤字段
